var prefix = jsctx + "/tenantTicketType";

var detialSendRecord = (function () {
    $('#exampleTable').on('load-success.bs.table', function (e, data) {
        if (data.total && !data.rows.length) {
            $('#exampleTable').bootstrapTable('selectPage').bootstrapTable('refresh');
        }
    });

    function reLoad() {
        $('#exampleTable').bootstrapTable('refresh');
        load();
    };

    function init() {
        setTimeout(function () {//防止先于-读取缓存执行
            load();
        },10)
    };

    function load() {
        $('#exampleTable')
            .bootstrapTable({
                method: 'get',
                url: prefix + "/listPageDetialSendRecord",
                iconSize: 'outline',
                toolbar: '#exampleToolbar',
                striped: false,
                dataType: "json",
                pagination: true,
                singleSelect: false,
                pageSize: 20,
                pageList: [20],
                pageNumber: 1,
                sidePagination: "server",
                cache: false,
                queryParams: function (params) {
                    return {
                        limit: params.limit,
                        offset: (params.offset / params.limit) + 1,
                        ticketSendRecordId: $("#ticketSendRecordId").val().trim(),
                        nickname: $("#nickname").val().trim(),
                        mobile: $("#mobile").val().trim(),
                        beginTime: $("#beginTime").val().trim(),
                        endTime: $("#endTime").val().trim(),
                        status: $("#status").val().trim(),
                    };
                },
                columns: [
                    {
                        field: 'number',
                        title: '序号',
                        width: '100', align: 'center',
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },

                    {field: 'nickname', title: '用户昵称', align: 'left'},
                    {field: 'mobile', title: '手机号', align: 'left'},
                    {field: 'sendTime', title: '赠送时间', align: 'left'},
                    {field: 'gainTime', title: '生效时间', align: 'left'},
                    {field: 'endTime', title: '失效时间', align: 'left'},
                    {
                        field: 'status',
                        title: '使用状态',
                        width: '100', align: 'left',
                        formatter: function (value, row, index) {
                            if (row.status == '0') {
                                return '未使用';
                            } else if (row.status == '1') {
                                return '已使用';
                            }
                        }
                    },
                    {field: 'usedTime', title: '使用时间', align: 'left'},
                ]
            });
    };

    return {
        init: init,
        reLoad: reLoad
    };
})();

